package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.TeachplanDTO;
import com.xuecheng.api.content.model.vo.TeachplanVO;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.ext.TeachplanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface TeachplanConvert {
    TeachplanConvert INSTANCE =Mappers.getMapper(TeachplanConvert.class);
    @Mappings({
            @Mapping(source = "id",target = "teachPlanId"),
            @Mapping(source = "childrenNodes",target = "teachPlanTreeNodes")
    })
    // 扩展po转dto
    TeachplanDTO entity2dto(TeachplanNode teachplan);
    @Mapping(source = "id",target = "teachPlanId")
    TeachplanDTO ent2dto(Teachplan teachplan);

    TeachplanDTO vo2dto(TeachplanVO vo);

    @Mapping(source = "teachPlanId",target = "id")
    //dto转po
    Teachplan dto2entity(TeachplanDTO teachplanDTO);
    //pos转dtos
    List<TeachplanDTO> entitys2dtos(List<TeachplanNode> teachplans);

}
